#!/usr/bin/env python2.6

from __future__ import division
from visual import *
import time

MAX_FPS = 50
DELTA_T = 1 / MAX_FPS

scene.autoscale = False
#scene.stereo = 'redblue'

if __name__ == '__main__':
    print 'hello'
    maxX = 10
    minX = -10
    maxY = 10
    minY = -10
    dwall = box(pos=vector(0, -10, 0), size=(20, 0.1, 5), color=color.white)
    lwall = box(pos=vector(-10, 0, 0), size=(0.1, 20, 5), color=color.white)
    rwall = box(pos=vector(10, 0, 0), size=(0.1, 20, 5), color=color.white)
    uwall = box(pos=vector(0, 10, 0), size=(20, 0.1, 5), color=color.white)

    balls = []
    ball = sphere(pos=vector(-4, -1, 0), radius=1, color=color.blue)
    ball.velocity = vector(15, 7, 0)
    balls.append(ball)
    ball = sphere(pos=vector(3, 1, 0), radius=1, color=color.blue)
    ball.velocity = vector(3, 7, 0)
    balls.append(ball)

    t = 0
    while True:
        rate(MAX_FPS)
        for ball in balls:
            if (ball.pos.x > maxX or ball.pos.x < minX):
                ball.velocity.x = -ball.velocity.x
            if (ball.pos.y > maxY or ball.pos.y < minY):
                ball.velocity.y = -ball.velocity.y
            ball.pos += DELTA_T * ball.velocity
            ball.velocity.y += -9.81 * DELTA_T
            #ball.velocity *= 0.995
            #t += DELTA_T

